Hệ thống quản lý nguồn nhân lực Dự án năm cuối trong c#

1 Imports System.Data.SqlClient
2
3 Public Class Frm_Login
4
5     Dim emp_id As Integer =
0
6
7     Private Sub formClear()
8         txtUserID.Clear()
9         txtPass.Clear()
10     End Sub
11
12     Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
13         Me.Close()
14     End Sub
15
16     Private Sub cmboxLoginType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmboxLoginType.SelectedIndexChanged
17
18         If cmboxLoginType.Text.Equals(
"Employee") Then
19
20             lblName.Text =
"Employee ID"
21
22             lblPass.Visible = False
23             txtPass.Visible = False
24
25             lblLogin.Location = New Point(
49, 130)
26             cmboxLoginType.Location = New Point(
157, 129)
27
28         ElseIf cmboxLoginType.Text.Equals(
"Admin") Then
29
30             lblName.Text =
"Admin Name"
31             lblLogin.Location = New Point(
49, 166)
32             cmboxLoginType.Location = New Point(
159, 166)
33
34             lblPass.Visible = True
35             txtPass.Visible = True
36
37         End If
38
39     End Sub
40
41     Public Function verifyEmployeeId() As Integer
42
43         Dim query =
"Select employee_id From Employee Where employee_id = '" & Convert.ToInt32(txtUserID.Text) & "'"
44         Dim dr As SqlDataReader = getDataReader(query)
45         dr.Read()
46         emp_id = dr(
"employee_id")
47         dr.Close()
48
49         Return emp_id
50
51     End Function
52
53     Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
54
55         Try
56
57             If cmboxLoginType.Text.Equals(
"Employee") AndAlso Convert.ToInt32(txtUserID.Text) = verifyEmployeeId() Then
58
59                 disableRights(Frm_Main.btnAdmin, Frm_Main.btnDeptt, Frm_Main.btnSearch, Frm_Main.btnEmployee, Frm_Main.MenuStrip)
60                 Frm_Employee_Performance.emp_id = Convert.ToInt32(txtUserID.Text)
61                 Frm_Main.flag =
0
62                 Frm_Main.flag3 =
0
63                 Frm_Main.Show()
64                 formClear()
65
66             ElseIf cmboxLoginType.Text.Equals(
"Admin") AndAlso txtUserID.Text.Equals("osama") AndAlso txtPass.Text.Equals("maverick") Then
67
68                 enableRights(Frm_Main.btnAdmin, Frm_Main.btnDeptt, Frm_Main.btnSearch, Frm_Main.btnEmployee, Frm_Main.MenuStrip)
69                 Frm_Main.Show()
70                 Frm_Main.flag =
1
71                 Frm_Main.flag3 =
1
72                 Frm_Main.btnLogout.Visible = True
73                 Frm_Main.btnAdmin.Enabled = False
74                 formClear()
75             Else
76
77                 MsgBox(
"Must Enter A Valid Login Details")
78
79             End If
80
81         Catch ex As Exception
82
83             If cmboxLoginType.Text.Equals(
"Employee") Then
84
85                 MsgBox(
"Must Enter A Valid Employee ID")
86
87             End If
88
89         End Try
90
91     End Sub
92
93     Private Sub txtPass_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtPass.KeyPress
94         If (Asc(e.KeyChar) =
13) Then
95             btnLogin_Click(sender, e)
96         End If
97     End Sub
98
99     Private Sub txtUserID_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtUserID.KeyPress
100         If (Asc(e.KeyChar) =
13) Then
101             btnLogin_Click(sender, e)
102         End If
103     End Sub
104 End Class


Gõ tìm kiếm nhanh...